﻿using System.Globalization;
using System.Threading;
using System.Web.Mvc;

namespace CasualisHTMLGames.Code.Localization {
    public class LocalizationAttribute : ActionFilterAttribute {
        public override void OnActionExecuting(ActionExecutingContext filterContext) {
            string culture = (filterContext.HttpContext.Session["SiteCulture"] != null) ? (filterContext.HttpContext.Session["SiteCulture"].ToString()) : (CultureInfo.CurrentCulture.ToString());
            CultureInfo cultureInfo = new CultureInfo(culture);
            Thread.CurrentThread.CurrentCulture = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;
        }
    }
}